home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / source / swaga-c / copymove.swg / 0020_Simple File Copy.pas < prev    next >
Pascal/Delphi Source File  |  1993-11-02  |  1KB  |  39 lines

  1. {
  2. From: IAN LIN
  3. To just copy files, use buffers on the heap. Just make an array type that's
  4. almost 64k in size. Use as many of these as needed that can fit in RAM and
  5. blockread the data in. After you blockread all you can, close the file if
  6. it's been fully read in. If it hasn't then don't close the input file yet.
  7. Next you open the output file and dump everything in each buffer with
  8. blockwrite. If you're done now, close both files, otherwise keep reading
  9. all you can at once from the input file and blockwriting it to the output
  10. file. }
  11.  
  12. type
  13.  pbuf=^buf;
  14.  buf=record
  15.   n:pbuf;
  16.   b:array [1..65530] of byte;
  17.  end;
  18. var
  19.  buffer,bufp:pbuf;
  20.  bufc:byte;
  21.  outf,f:file;
  22. begin
  23.  bufp:=new(buffer);
  24.  assign(f,'IT');
  25.  reset(f,1);
  26.  blockread(f,bufp^,sizeof(bufp^);
  27.  assign(outf,'OTHER');
  28.  rewrite(outf,1);
  29.  blockwrite(outf,bufp^,sizeof(bufp^);
  30.  close(f);
  31.  close(outf);
  32. end.
  33.  
  34. This is just an example so don't expect it to be very useful. :)
  35.  
  36. For text files, if you want to modify them, you may want to use linked
  37. lists which point to a line at a time. Remove unwanted lines from the list,
  38. and then write it to the output file.
  39.